package com.xm.xmapp.http;

import com.android.volley.AuthFailureError;
import com.android.volley.NetworkError;
import com.android.volley.NoConnectionError;
import com.android.volley.Response;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;


/**
 * Created by LDW on 2017/7/14.
 */
public class NetWorkError implements Response.ErrorListener {

    private NetWorkData mNetWorkData;
    private int code;
    public NetWorkError(NetWorkData mNetWorkData , int code){
        this.mNetWorkData = mNetWorkData;
        this.code = code;
    }

    @Override
    public void onErrorResponse(VolleyError volleyError) {
        if(mNetWorkData !=null) {
            mNetWorkData.dissMissDialog(code);
        }
        if (volleyError instanceof TimeoutError) {
//            Tools.showNetMessage("连接超时");
        } else if ((volleyError instanceof ServerError) || (volleyError instanceof AuthFailureError)) {
//            Tools.showNetMessage("服务器错误");

        } else if ((volleyError instanceof NetworkError) || (volleyError instanceof NoConnectionError)) {
//            Tools.showNetMessage("网络不给力，请检查网络设置");
        }
    }
}
